package framework.base;

import org.hibernate.AssertionFailure;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.internal.util.StringHelper;



/**
 * Hibernate
 * @author jinchaoyang
 */
public class DBNamingStrategy extends ImprovedNamingStrategy{

    private static final long serialVersionUID = 1L;

    public String foreignKeyColumnName(
            String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
    ) 
    {
        String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
        if (header == null) throw new AssertionFailure("NamingStrategy not properly filled");
        return columnName( header+"_id" ); 
        }
    
}
